import React from "react"
import { Outlet, useNavigate } from "react-router-dom"
class BasiceUse extends React.Component{
  constructor(props) {
    super(props)
    this.state = {
      'p':'zs'
    }
    this.f3 = this.f3.bind(this)//绑定this
  }
  f1 = (e) => {//箭头函数使用,自动绑定当前this
    console.log(e,this.state.p)
  }
  f2(e){
    console.log(e,this.state.p)
  }
  f3(e){
    console.log(e,this.state.p)
  }
  
  render() {
    return (
      <div>
        <button onClick={this.f1}>f1:把箭头函数传过去</button>
        <button onClick={(e)=>this.f2(e)}>f2:包装成箭头函数传过去,</button>
        <button onClick={this.f3}>f3:bindthis</button>
      </div>
    )
  }
  
}
export default BasiceUse